package com.steven.im.adapter;

import android.widget.TextView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.makeramen.roundedimageview.RoundedImageView;
import com.squareup.picasso.Picasso;
import com.steven.im.App;
import com.steven.im.R;

import java.util.List;


/**
 * Created by Steven on 2019/1/8.
 */
public class FoundRecycleAdapter extends BaseQuickAdapter<Object, BaseViewHolder> {
    private List<Object> list;

    public FoundRecycleAdapter(List<Object> newsList) {
        super(R.layout.found_item, newsList);
        this.list = newsList;
    }


    @Override
    protected void convert(BaseViewHolder helper, Object item) {
        String title = ((JSONObject) (JSON.toJSON(list.get(helper.getPosition())))).getString("title");
        String linkUrl = ((JSONObject) (JSON.toJSON(list.get(helper.getPosition())))).getString("imageUrl");
        ((TextView) helper.getView(R.id.tweetName)).setText(title);
        Picasso.with(App.getContext()).load(linkUrl).into(((RoundedImageView) helper.getView(R.id.img)));
    }
}
